/******************************发行客户实销上报统计【按日】*************************/
var divIds=new Array();
divIds[0]="client_zq_datalist";

/***
 * 初始化界面
 * @return
 */
function initcwsqMulRep(){
    var date=$("#commConfig input[qucln=IMPORT_DATE]").val();
    if(date==""||date==null){
        var inputDate = new Date();
        date=inputDate.format("yyyy-MM");
        $("#commConfig input[qucln=IMPORT_DATE]").val(date);
    }
    //for(var i=0,len=divIds.length;i<len;i++){
    var options = jointDGColumnCwsq(divIds[0],date);// 根据配置选项，生成datagrid
    var divId=divIds[0];
    $('#'+divId).datagrid({
        showFooter:true,
        iconCls:'icon-save',
        striped: true,
        collapsible:true,
        autoRowHeight: false,
        sortOrder: 'desc',
        remoteSort: false,
        columns:options.columns,
        frozenColumns:options.frozenColumns,
        rownumbers:true,
        singleSelect:true
    });
    //}
}

/***********************************************
 * 客户实销上报统计【按日】查询按钮触发的事件
 * @param obj
 * @return
 ***********************************************/
function _wsq_query(){
    var selectTab=$("div[id=client_zq_dgparent]").tabs('getSelected');
    var dgDiv=$(selectTab).find($("div[dsId]"));
    var dsId=$(dgDiv).attr('dsId');
    var divId=$(dgDiv).attr('id');
    var dateVal=$("#commConfig input[qucln=IMPORT_DATE]").val();
    if(dateVal==null||dateVal==""){
        $.messager.alert("提示","请选择日期");
        return;
    }
    var date = new Date(dateVal);
    var options = jointDGColumnCwsq(divId,date);// 根据配置选项，生成datagrid
    var cureetime=date.getFullYear() + "-" + (date.getMonth()+1);
    date.setMonth(date.getMonth()-1);
    $(dgDiv).datagrid({
        columns:options.columns,
        frozenColumns:options.frozenColumns,
        url:_m_url+'fxa/loadclientbyData',
        queryParams:{"dsId":dsId,"date1":cureetime}//,"date2":lastmonth,"date3":lastyear
    });
}

/***********************************************
 * 客户实销上报统计【按日】查询导出事件
 * @param obj
 * @return
 ***********************************************/
function _wsq_queryforexport(){
    var selectTab=$("div[id=client_zq_dgparent]").tabs('getSelected');
    var dgDiv=$(selectTab).find($("div[dsId]"));
    var dsId=$(dgDiv).attr('dsId');
    var divId=$(dgDiv).attr('id');
    var dateVal=$("#commConfig input[qucln=IMPORT_DATE]").val();
    if(dateVal==null||dateVal==""){
        $.messager.alert("提示","请选择日期");
        return;
    }
    var date = new Date(dateVal);
    var cureetime=date.getFullYear() + "-" + (date.getMonth()+1);

    //location.href=_m_url+"fxa/TbHbDataforexport?dsId="+dsId+"&date1="+cureetime+"&date2="+lastmonth+"&date3="+lastyear;
    location.href=_m_url+"fxa/jxlfords_client_zq_dgparent1?dsId="+dsId+"&date1="+cureetime;
}


/*************************
 * 拼接客户实销上报统计【按日】datagrid 的列
 * @return
 */
function jointDGColumnCwsq(divId,date){
    var date = new Date(date);
    var cureetime=date.getFullYear() + "-" + (date.getMonth()+1);
    if(divId=='client_zq_datalist'){
        var options= {
            rownumbers: true
        };
        var newColumns1 = new Array();
        var froColumns = new Array();
        froColumns[0] ={field:'kk',checkbox:true};
        newColumns1 = [
            {field: "H_ID",title:'<span class="tbhbrep">商品名称</span>',width:'200',align:"center",formatter:eval('window.parent.dz_productlistfmat'),sortable:true},
            {field: "H_PRICE",title:'<span class="tbhbrep">定价</span>',width:'50',align:"center",sortable:true},
            {field: "ONE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-1日</span>', align: "center", width: '75',sortable:true},
            {field: "TWO_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-2日</span>', align: "center", width: '75',sortable:true},
            {field: "THREE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-3日</span>', align: "center", width: '75',sortable:true},
            {field: "FOUR_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-4日</span>', align: "center", width: '75',sortable:true},
            {field: "FIVE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-5日</span>', align: "center", width: '75',sortable:true},
            {field: "SIX_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-6日</span>', align: "center", width: '75',sortable:true},
            {field: "SEVEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-7日</span>', align: "center", width: '75',sortable:true},
            {field: "EIGHT_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-8日</span>', align: "center", width: '75',sortable:true},
            {field: "NINE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-9日</span>', align: "center", width: '75',sortable:true},
            {field: "TEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-10日</span>', align: "center", width: '85',sortable:true},
            {field: "ELEVEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-11日</span>', align: "center", width: '85',sortable:true},
            {field: "TWELVE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-12日</span>', align: "center", width: '85',sortable:true},
            {field: "THIRTEEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-13日</span>', align: "center", width: '85',sortable:true},
            {field: "FOURTEEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-14日</span>', align: "center", width: '85',sortable:true},
            {field: "FIFTEEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-15日</span>', align: "center", width: '85',sortable:true},
            {field: "SIXTEEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-16日</span>', align: "center", width: '85',sortable:true},
            {field: "SEVENTEEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-17日</span>', align: "center", width: '85',sortable:true},
            {field: "EIGHTEEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-18日</span>', align: "center", width: '85',sortable:true},
            {field: "NINETEEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-19日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-20日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_ONE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-21日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_TWO_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-22日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_THREE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-23日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_FOUR_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-24日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_FIVE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-25日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_SIX_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-26日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_SEVEN_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-27日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_EIGHT_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-28日</span>', align: "center", width: '85',sortable:true},
            {field: "TWENTY_NINE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-29日</span>', align: "center", width: '85',sortable:true},
            {field: "THIRTY_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-30日</span>', align: "center", width: '85',sortable:true},
            {field: "THIRTY_ONE_AMOUNT", title: '<span class="tbhbrep">'+cureetime+'-31日</span>', align: "center", width: '85',sortable:true}

        ]

        var cc = new Array();
        var fc = new Array();
        cc[0] = newColumns1;
        fc[0] = froColumns;
        options.columns = (cc);
        options.frozenColumns = (fc);
        return options;




    }
}



